package Object类编程题;

import java.util.Objects;

public class Student {
    private String name;
    private String gender;
    private int age;

    public Student(String name, String gender, int age) {
        this.name = name;
        this.gender = gender;
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && Objects.equals(name, student.name) && Objects.equals(gender, student.gender);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, gender, age);
    }
}
class TestStudent{
    public static void main(String[] args) {
        var s1 = new Student("Tiny","Male",18);
        var s2 = new Student("Amy","Female",20);
        System.out.println(s1.equals(s2));
    }
}
